import request from "@/utils/request";

import type {
  AttrListParams,
  SaveAttrParams,
  GetAttrListResponse,
} from "@/api/product/model/attrModel";

enum Api {
  getAttrListUrl = "/admin/product/attrInfoList",
  saveAttrListUrl = "/admin/product/saveAttrInfo",
  delAttrUrl = "/admin/product/deleteAttr",
}

//获取属性列表
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: AttrListParams) => {
  return request.get<any, GetAttrListResponse>(
    Api.getAttrListUrl + `/${category1Id}/${category2Id}/${category3Id}`
  );
};

//添加属性
export const saveAttrListUrlApi = (tm: SaveAttrParams) => {
  return request.post<any, null>(Api.saveAttrListUrl, tm);
};
export const delAttrApi = (id: number) => {
  return request.delete<any, null>(Api.delAttrUrl + `/${id}`);
};
